// 定义设计稿的宽高
const WIDTH_DESIGN = 1920
const HEIGHT_DESIGN = 980

// px转vw
export const px2vw = (_px: number, withUnit = true) => {
  let r = (_px * 100.0) / WIDTH_DESIGN
  if (withUnit) {
    return r + 'vw'
  }
  return r
}

export const px2vh = (_px: number, withUnit = true) => {
  let r = (_px * 100.0) / HEIGHT_DESIGN
  if (withUnit) {
    return r + 'vh'
  }
  return r
}
export const fitChartSize = (size: number) => {
  let clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
  if (!clientWidth) return size
  let scale = clientWidth / WIDTH_DESIGN
  return Number((size * scale).toFixed(3))
}
